package com.sh.controller;

import com.sh.service.UserService;
import com.sh.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    //登录功能
    @RequestMapping("login")
    public ResultUtil login(String username,String password){
        ResultUtil login = userService.login(username, password);
        return login;
    }

    //展示数据带查询
    @RequestMapping("show")
    public ResultUtil show(String username){
        ResultUtil show = userService.show(username);
        return show;
    }

    //添加用户
    @RequestMapping("insert")
    public ResultUtil insert(String username, String truename, String password){
        ResultUtil insert = userService.insert(username, truename, password);
        return insert;
    }

    //修改用户
    @RequestMapping("update")
    public ResultUtil update(Integer id, String username, String truename){
        ResultUtil update = userService.update(id, username, truename);
        return update;
    }

    //删除用户
    @RequestMapping("del")
    public ResultUtil del(Integer id){
        ResultUtil del = userService.del(id);
        return del;
    }
}
